package com.ymatou.iapi.livebuyer.testcase;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.DebugBean;
import com.ymatou.iapi.livebuyer.parameter.SendTimBroadcastBean;
import com.ymatou.iapi.livebuyer.service.SendTimBroadcastCall;
import com.ymatou.iapi.liveseller.parameter.CreateLiveActivityBean;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.database.model.LiveActivitySubscribe;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
/**
*发送秒杀活动订阅通知
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SendTimBroadcast{
	private static com.ymatou.iapi.livebuyer.parameter.SendTimBroadcastBean SendTimBroadcastBean;
	private static com.ymatou.iapi.livebuyer.service.SendTimBroadcastCall SendTimBroadcastCall;
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发送秒杀活动订阅通知");
	}

	@Before
	public void caseUp() {
		SendTimBroadcastBean=new SendTimBroadcastBean();
		SendTimBroadcastCall=new SendTimBroadcastCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(SendTimBroadcastCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendTimBroadcast_001() {
		Logger.start(true,"发送广播TimBroadcast通知成功");
		try {
			LiveRoomWapper LiveRoomWapper=new LiveRoomWapper();
			int uid=2;
			Logger.comment("创建直播");
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			Date starttime = new Date(now.getTime() + 4*60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), sellerId);
			Thread.sleep(3000);
			SendTimBroadcastBean.setBizType(901);
//			SendTimBroadcastBean.setLiveIds(Arrays.asList(createlive.getId()));
			DebugBean DebugBean=new DebugBean();
			DebugBean.setDebugId("debug");
			DebugBean.setLiveId(createlive.getId());
			SendTimBroadcastBean.setBizData(FormatUtil.beanToGSONString(DebugBean));
			SendTimBroadcastCall.setData(SendTimBroadcastBean);
			SendTimBroadcastCall.callService();			
			Logger.verifyEquals("200",SendTimBroadcastCall.getString("code"), "验证返回");
			//验证日志
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}